package FastJosnTest.StudentToJson;

import com.alibaba.fastjson.JSON;

import java.io.*;

public class StuToJson {
    public static void main(String[] args) throws Exception{
        Writer writer = new OutputStreamWriter(new FileOutputStream("D:\\MP\\students\\input\\students.json"));
        BufferedReader reader = new BufferedReader(new FileReader("D:\\MP\\students\\input\\students.txt"));
        String line;
        Students students = new Students();
        while ((line=reader.readLine())!=null){
            String [] datas = line.split(",");
            students.set(Long.parseLong(datas[0]),datas[1],Integer.parseInt(datas[2]),datas[3],datas[4]);
            String json = JSON.toJSONString(students);
            System.out.println(json);
            writer.write(json+"\n");
            writer.flush();
        }
        reader.close();
        writer.close();
    }
}
